package com.linyaonan.leetcode.easy._54;


class Solution {

    private static int get_Num = 0;

    private static int max = 0;

    public int kthLargest(TreeNode root, int k) {
        get_Num = 0;
        max = k;
        try {
            dfsNode(root);
        } catch (Exception ignored) {
        }
        return get_Num;
    }

    private void dfsNode(TreeNode node) {
        if (node != null) {
            dfsNode(node.right);
            System.out.println(node.val);
            if (--max == 0) {
                get_Num = node.val;
                throw new RuntimeException("get it");
            }
            dfsNode(node.left);
        }
    }
}